#include "Vx.h"
#include "Controls/vxtextitem.h"

bool Vx::haveEditing(QGraphicsScene * scene)
{

	foreach(QGraphicsItem * obj, scene->items()){

		if (obj->type() != VxTextItem::Type){
			continue;
		}

		VxTextItem * ti = dynamic_cast<VxTextItem *>(obj);
		if (ti->textInteractionFlags() == Qt::TextEditorInteraction){
			return true;
		}

	}

	return false;
}


void Vx::setCacheMode(QGraphicsScene * scene, QGraphicsItem::CacheMode mode, qreal scale)
{

	foreach(QGraphicsItem * item, scene->items()){
		QRectF r = item->boundingRect();
		item->setCacheMode(mode, QSize(r.width()*scale, r.height()*scale));
	}
}

QPointF Vx::viewPoint(QGraphicsView * view)
{
	qreal width = view->viewport()->width();
	qreal height = view->viewport()->height();
	return view->mapToScene(QPoint(width/2, height/2));
}

int Vx::setScale(QGraphicsView * view, int scale)
{
	view->resetMatrix();
	view->scale(scale, scale);
	return scale;
}




